<template>
  <div class="w-full h-[calc(100vh-160px)] overflow-y-scroll">
    <div
      v-for="(item, index) in list"
      :key="index"
      class="w-full flex flex-row justify-between items-center p-3 hover:bg-CenterHover rounded"
    >
      <div class="flex flex-row justify-center items-center gap-2">
        <n-avatar round :src="item.avatar" />
        <div>
          <p class="text-base text-fontPrimary">{{ item.name }}</p>
          <p class="text-xs text-fontSecondary">
            {{ item.sign }}
          </p>
        </div>
      </div>
      <div class="text-end">
        <el-button :disabled="item.status != 0" size="small" @click="emit('confirmJoin', item)">
          {{ StatusName(item) }}
        </el-button>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ISearchFriendItem } from "@/types/friend";
import { computed } from "vue";
import { NAvatar } from "naive-ui";

const emit = defineEmits(["confirmJoin"]);
defineProps({
  list: {
    type: Array as () => ISearchFriendItem[],
    default: () => [],
  },
});

const StatusName = computed(() => {
  return (item: ISearchFriendItem) => {
    switch (item.status) {
      case 0:
        return "添加好友";
      case 1:
        return "已经是好友";
      case 2:
        return "已经被拒绝";
      default:
        return "添加好友";
    }
  };
});
</script>

<style lang="scss" scoped></style>
